<div class="main-content">
    <div class="section__content section__content--p20">
        <div class="container-fluid">
            <div class="row m-b-30">
                <div class="col-lg-12">
                    <div class="overview-wrap">
                        <h2 class="title-1">用户列表</h2>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="table-responsive table--no-card m-b-30">
                        <table class="table table-borderless table-striped table-earning">
                            <thead>
                            <tr>
                                <th>登入名</th>
                                <th>用户名</th>
                                <th>邮箱</th>
                                <th>电话</th>
                                <th>手机</th>
                                <th>有效</th>
                                <th>工具</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if (sizeof($list) > 0) {
                                foreach ($list as $u) {
                                    ?>
                                    <tr>
                                        <td><?php echo $u['loginname']; ?></td>
                                        <td><?php echo $u['username']; ?></td>
                                        <td><?php echo $u['email']; ?></td>
                                        <td><?php echo $u['tel']; ?></td>
                                        <td><?php echo $u['phone']; ?></td>
                                        <td><?php echo $u['isvalid'] == 1 ? "<i class=\"fa fa-check-square\"></i>" : "<i class=\"fa fa-minus-square\"></i>"; ?></td>
                                        <td>
                                            <button class="btn btn-primary btn-sm"
                                                    onclick="showedit(<?php echo $u['user_id']; ?>)">编辑
                                            </button>
                                            <button class="btn btn-danger btn-sm"
                                                    onclick="del(<?php echo $u['user_id']; ?>)">删除
                                            </button>
                                        </td>
                                    </tr>
                                    <?php
                                }
                            }

                            ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="row ">
                <div class="col-lg-12 text-center">
                    <div style="display: inline-block;"><?php
                        $this->widget('CLinkPager', array(
                                'header' => '',
                                'firstPageLabel' => '首页',
                                'lastPageLabel' => '末页',
                                'prevPageLabel' => '上一页',
                                'nextPageLabel' => '下一页',
                                'pages' => $pages,
                                "selectedPageCssClass" => 'active',
                                'htmlOptions' => Array('class' => 'pagination pagination_customize')
                            )
                        );
                        ?></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function showedit(id) {
        if (id == 0) {
            window.location.href = "index.php?r=admin/user/add&id=" + id;
            return;
        }
        window.location.href = "index.php?r=admin/user/showedit&id=" + id;
    }

    function del(id) {
        $("#confirmModal_text").text('是否删除用户？');
        $("#confirmModalButton").bind("click",function () {
            $.get('index.php?r=admin/user/del', {id: id}, function (result) {
                if (result.type == true) {
                    window.location.href = "index.php?r=admin/user/index";
                } else {
                    alert(result.message);
                }
            }, 'json');
        });
    }
</script>